<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="root">
    <h2 v-if="a">你好啊</h2>
    <h2 :style="{opacity}">欢迎学习Vue</h2>
    {{change()}}
</div>
</body>
<script type="text/javascript">
    Vue.config.productionTip=false
    const vm=new Vue({
        el:'#root',
        data:{
            opacity:1
        },
        methods:{

        },
        //挂载（）
        mounted(){
            console.log('mounted',this)
                setInterval(()=>{
                    this.opacity-=0.01
                    if (this.opacity<= 0) this.opacity=1
                },16)
        }
    })
    //通过外部定时器实现（不推荐)
    //     setInterval(()=>{
    //         this.opacity-=0.01
    //         if (this.opacity<= 0) this.opacity=1
    //     },16)
    // }
</script>
</html>